package pl.easyshop.core.dao.hibernate;

import org.springframework.stereotype.Repository;

import pl.easyshop.core.dao.UserDAO;
import pl.easyshop.core.dao.common.hb.HbAbstractGenericDAO;
import pl.easyshop.core.model.UserModel;

/**
 * Hibernate implementation of {@link UserDAO} interface.
 * 
 * @author Pawel Witkowski
 */
@Repository("hbUserDAO")
public class HbUserDAO extends HbAbstractGenericDAO<UserModel> implements UserDAO {

	@Override
	public UserModel findById(Long id) {
		return load(id);
	}

	@Override
	public UserModel findByUserName(String username) {
		final String hql = "from UserModel where username=:username";
		UserModel result = (UserModel) getCurrentSession().createQuery(hql).setParameter("username", username).uniqueResult();
		return result;
	}

	

}
